package com.example.administrator.yunniuusedcar.activity;

import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.administrator.common.base.BaseActivity;
import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.adapter.MainAdapter;
import com.example.administrator.yunniuusedcar.fragment.ShoppInfo_Fragment.GuiGeInfoFragment;
import com.example.administrator.yunniuusedcar.fragment.ShoppInfo_Fragment.JiBenInfoFragment;
import com.example.administrator.yunniuusedcar.fragment.ShoppInfo_Fragment.PingJiaFragment;
import com.example.administrator.yunniuusedcar.fragment.ShoppInfo_Fragment.TuWenInfoFragment;
import com.example.administrator.yunniuusedcar.mineModular.ShoopingCarActivity;
import com.example.administrator.yunniuusedcar.mineModular.YuYueActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

// 豪车精品  (Tablayout + viewPager + Fragment)

public class HaoCarJingPingActivity extends BaseActivity {


    @BindView(R.id.tab_commodityInfo)
    TabLayout tabCommodityInfo;
    @BindView(R.id.vp_commodityInfp)
    ViewPager vpCommodityInfp;
    @BindView(R.id.IV_erroPAGE)
    ImageView IVErroPAGE;
    @BindView(R.id.LL_keFuZiXun)
    LinearLayout LLKeFuZiXun;
    @BindView(R.id.iv_shuoCang)
    ImageView ivShuoCang;
    @BindView(R.id.LL_JiaRuShouCang)
    LinearLayout LLJiaRuShouCang;
    @BindView(R.id.bt_JiaRuShoopCar)
    Button btJiaRuShoopCar;
    @BindView(R.id.bt_LiJiGuoMai)
    Button btLiJiGuoMai;
    private ImageView iv_backs;
    private ImageView ivJiSuan;

    @Override
    public int getLayoutRes() {
        return R.layout.activity_jingping_details;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
        iv_backs = findView(R.id.iv_back);
        iv_backs.setOnClickListener(new View.OnClickListener() {    //返回图片
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        initViewPaer();
        initTabLayout();
        intiFV();
    }

    private void intiFV() {
        ivJiSuan = findView(R.id.iv_JiSuan);

    }


    String[] titless = {"综合排序","销量优先","价格排序","筛选"};
    private void initViewPaer() {
        List<Fragment> fragmens = new ArrayList<>();
        fragmens.add(new JiBenInfoFragment(0));    //看情况修改
        fragmens.add(new TuWenInfoFragment(0));
        fragmens.add(new GuiGeInfoFragment(0));
        fragmens.add(new PingJiaFragment(0));

        MainAdapter mainAdapters = new MainAdapter(getSupportFragmentManager(),fragmens,titless);

        vpCommodityInfp.setAdapter(mainAdapters);

    }

    private void initTabLayout() {
        tabCommodityInfo.setupWithViewPager(vpCommodityInfp);
    }




    @Override
    public void initListener() {

    }

    @Override
    public void initData() {

    }
    @OnClick({R.id.LL_keFuZiXun, R.id.LL_JiaRuShouCang,R.id.iv_JiSuan, R.id.bt_JiaRuShoopCar, R.id.bt_LiJiGuoMai})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.LL_keFuZiXun:    // 客服咨询
                Intent intent = new Intent(HaoCarJingPingActivity.this, YuYueActivity.class);
                startActivity(intent);
                break;
            case R.id.LL_JiaRuShouCang:   // 加入收藏
                break;
            case R.id.bt_JiaRuShoopCar:   // 加入购物车
            startActivity(new Intent(HaoCarJingPingActivity.this, ShoopingCarActivity.class));
                break;
            case R.id.bt_LiJiGuoMai:    // 立即购买
                break;
            case R.id.iv_JiSuan:        //购车计算
                startActivity(new Intent(HaoCarJingPingActivity.this,BuyCarCountActivity.class));
                break;
        }
    }
}
